package com.example.controller;

import com.example.common.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 首页控制器
 */
@RestController
public class IndexController {
    
    /**
     * 首页接口
     */
    @GetMapping("/")
    public Result<Map<String, Object>> index() {
        Map<String, Object> info = new HashMap<>();
        info.put("name", "HAI Backend API");
        info.put("version", "1.0.0");
        info.put("status", "running");
        
        Map<String, String> endpoints = new HashMap<>();
        endpoints.put("products", "/api/v1/products");
        endpoints.put("product_detail", "/api/v1/products/{id}");
        endpoints.put("creator_cards", "/api/v1/creator-cards");
        endpoints.put("contact_configs", "/api/v1/contact/configs");
        endpoints.put("contact_form", "/api/v1/contact/forms");
        
        info.put("endpoints", endpoints);
        
        return Result.success(info);
    }
    
    /**
     * 健康检查接口
     */
    @GetMapping("/health")
    public Result<String> health() {
        return Result.success("OK");
    }
    
    /**
     * API 信息接口
     */
    @RequestMapping("/api")
    public Result<Map<String, Object>> api() {
        return index();
    }
    
    /**
     * API v1 信息接口
     */
    @RequestMapping("/api/v1")
    public Result<Map<String, Object>> apiV1() {
        return index();
    }
} 